package com.zhongyouyun.web.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhongyouyun.admin.model.RoleModel;
import com.zhongyouyun.admin.model.SiteListModel;
import com.zhongyouyun.admin.service.SiteListService;
import com.zhongyouyun.other.model.PageRequest;
import com.zhongyouyun.other.model.Result;
import com.zhongyouyun.utils.QueryUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author: shenyi
 * @Date: 2021-12-17
 * @Description:
 */
@Controller
@RequestMapping("/web/home")
@Api(value = "三方登录认证", tags = {"三方登录认证"})
public class HomeController {
    @Autowired
    private SiteListService siteListService;
    @PostMapping("/findHomeSiteList")
    @ResponseBody
    @ApiOperation(value = "获取应用列表", notes = "获取应用列表")
    @ApiResponses({
            @ApiResponse(code=0,message = "操作成功",response = RoleModel.class)
    })
    public Result<List<SiteListModel>> findHomeSiteList(@RequestBody PageRequest pageRequest) {
        QueryWrapper<SiteListModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("in_use","1");
        QueryUtils.fiterQuery(queryWrapper, pageRequest);
        queryWrapper.orderByAsc("order_number");
        List<SiteListModel> list=siteListService.selectList(queryWrapper);
        if (list.size() > 0) {
            System.out.println("---------------------");
            return  Result.<List<SiteListModel>>builder().message("成功").status(0).data(list).build();
        } else {
            return Result.<List<SiteListModel>>builder().message("没有任何权限").status(1).build();
        }
    }

}
